package com.bwf.string;

import java.nio.charset.StandardCharsets;

/**
 * @Version v1.0
 * @Description: TODO
 * @Author ZHANZHONGXIN
 * @Date 2022/5/12 13:43
 * @Copyright 博为峰
 */
public class Encode {
    public static void main(String[] args) {
        /*
           字符编解码：
           1.编码
           2.解码
         */

        String s1 = "你";
        //StandardCharsets.UTF_8
//        byte[] bytes = s1.getBytes(); //-28,-67,-96,

        byte[] bytes = s1.getBytes(StandardCharsets.UTF_8);//-28,-67,-96, //编码

        for (int i = 0; i < bytes.length; i++) {
//            System.out.print(bytes[i] + ",");
        }

        String s = new String(bytes, StandardCharsets.ISO_8859_1);//解码
        System.out.println("s = " + s);

    }
}
